package com.yzh.homework.homework01;

/**
 * @author 于振晗
 * @title: Circle
 * @description: TODO 圆类
 * @date 2020年08月26日
 * @path com.yzh.homework.homework01
 */
public class Circle {
    private double radius;
    public Circle(){//将半径设为0
        radius = 0;
    };
    public Circle(double radius){//创建Circle对象时将半径初始化为radius
        this.radius = radius;
    };

    public double getArea(){//获取圆的面积
        return Math.pow(radius,2)*Math.PI;
    }
    public double getPerimeter(){//获取圆的周长
        return Math.PI*radius*2;
    }
    public void show(){//将圆的半径、周长、面积输出到屏幕
        System.out.println("半径："+radius);
        System.out.println("周长："+getPerimeter());
        System.out.println("面积："+getArea());
    }
}

class Cylinder extends Circle{
    private double hight; //圆柱
    public Cylinder(){

    }
    public Cylinder(double radius,double hight){
        super(radius);
        this.hight = hight;
    }

    public double getVolume(){//获取圆柱体的体积
        return super.getArea()*this.hight;
    }
    public void showVolume(){//将圆柱体的体积输出到屏幕
        System.out.println("体积："+getVolume());
    }

    public static void main(String[] args) {
        Cylinder cylinder = new Cylinder(5, 6);
        cylinder.show();
        cylinder.showVolume();
    }

}